<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>Document</title>
	<script type="text/javascript">
	function css(obj,name,value){
		if(arguments.length==2){
			return obj.style[name];   //获取值
			//return arguments[0].style[arguments[1]];
		}else{
			return obj.style[name]=value;  //设置值
			//return arguments[0].style[arguments[1]]=arguments[2];
		}
	}
		window.onload=function (){
              var oDiv=document.getElementById("div1");
              alert(css(oDiv,'width'));
		}
	</script>
</head>
<body>
	<div id="div1" style="width:200px;height:200px;background:red;"></div>
</body>
</html>